#include <QtQuick/QQuickView>
#include <QGuiApplication>
#include <QQmlEngine>
#include <QQmlComponent>
#include <QQmlContext>
#include <QQuickWindow>
#include <QObject>

#include "mainboard.h"
#include "windowcontrol.h"

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    qmlRegisterType<MainBoard>("MainBoard", 1, 0, "MainBoard");

    QQmlEngine engine;
    QQmlComponent component(&engine, QUrl("qrc:///player_ui/player_ui.qml"));
    QQuickWindow *window = qobject_cast<QQuickWindow *>(component.create());
//    QObject *object = (QObject *)(engine.rootContext()->contextObject());
    QObject::connect((QObject*)&engine, SIGNAL(quit()), &app, SLOT(quit()));

    WindowControl *control = new WindowControl;
    control->SetWindow(window);

//    QObject::connect((QObject *)window, SIGNAL(minimized_window()), control, SLOT(show_minimized_window()));
//    QObject::connect((QObject *)window, SIGNAL(maximized_window()), control, SLOT(show_maximized_window()));
    QObject::connect((QObject *)window, SIGNAL(windowStateChanged(Qt::WindowState)), control, SLOT(window_state_changed(Qt::WindowState)));
    window->setMinimumSize(QSize(800, 600));
    window->show();

    return app.exec();
}
